#pragma strict

class MathEx{
	/** 概率[0,1],尝试此概率有没有发生.
		return bool
	*/
	static function Probability(value:float){
		var digit:int = PointAfterLength(value);
		var base:int = Math.Pow(10,digit);
		var item:int = value * base;
		var target:int = Random.Range(0,base);
		return target < item;
	}
	/** 返回 小数点后的数字长度.*/
	static function PointAfterLength(value:float):int{
		var str:String = value.ToString();
		var index:int = str.IndexOf(".");
		return str.Substring(index+1).length;
	}
	
	static function AngleXZ(from:Vector3,to:Vector3):float{
		var dir:Vector3 = to - from;
		return Mathf.Atan2(dir.x,dir.z) * Mathf.Rad2Deg;
	}
	
}